package com.gosling.cloudspace.common.exception;

import com.gosling.cloudspace.common.constants.CommonConstants;
import com.gosling.cloudspace.common.constants.PrometheusTitleEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 指定监控类异常 PrometheusException
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class PrometheusException extends RuntimeException {

    /**
     * 业务错误码
     */
    private Integer code;
    /**
     * 错误提示
     */
    private String message;
    /**
     * 业务描述
     */
    private String title;
    /**
     * 业务分类
     */
    private String type;

    public PrometheusException(PrometheusTitleEnum title, String message) {
        this.type = title.getType();
        this.title = title.getName();
        this.code = title.getCode();
        this.message = message;
    }

    public PrometheusException(String message) {
        this.code = CommonConstants.NO;
        this.message = message;
    }

    @Override
    public String getMessage() {
        return message;
    }

}
